import base from './src/main';
import cloudbase from "@cloudbase/js-sdk";

function useCloud() {
    return cloudbase
}

export {
    useCloud
}

export default {
    install(wf) {

        let cloud = cloudbase

        // 初始化cloudApi
        const cloudApi = {};
        const apiMap = base.api;

        Object.keys(apiMap).forEach((funcName) => {
            const func = apiMap[funcName];
            cloudApi[funcName] = func.bind(cloud);
        });

        // 添加模块
        wf.addModule('cloud', cloud);
        wf.addModule('cloudApi', cloudApi);

        // 测试代码
        // cloud
        // 	.auth()
        // 	.signInAnonymously()
        // 	.then(() => {
        // 		console.log('登录云开发成功！', cloudApi);
        // 	});
    },
};

